<!DOCTYPE html>
<html lang="zh-CN">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <script type="text/javascript" src="../../scripts/jquery/jquery-1.7.1.js"></script>
    <link href="../../style/authority/basic_layout.css" rel="stylesheet" type="text/css">
    <link href="../../style/authority/common_style.css" rel="stylesheet" type="text/css">
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script type="text/javascript" src="../../scripts/authority/commonAll.js"></script>
    <script type="text/javascript" src="../../scripts/fancybox/jquery.fancybox-1.3.4.js"></script>
    <script type="text/javascript" src="../../scripts/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
    <link rel="stylesheet" type="text/css" href="../../style/authority/jquery.fancybox-1.3.4.css" media="screen"></link>
    <script type="text/javascript" src="../../scripts/artDialog/artDialog.js?skin=default"></script>
    <title>个人信息管理系统</title>
    <script type="text/javascript">

        function GetQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);//search,查询？后面的参数，并匹配正则
            if (r != null) return unescape(r[2]);
            return null;
        }
        var myname = GetQueryString("name");


        function UpdateInformation() {
            //var name = document.getElementById("username").value;
            //var name2 = document.getElementById("usercode").value;
            // alert(name2);
            var old_password = document.getElementById("old_password").value;
            var new_password = document.getElementById("new_password").value;
            var new_password_again = document.getElementById("new_password_again").value;
           // if(name!=name2){alert("仅可修改当前用户密码");return;}
            if ( old_password == "" || new_password == "" || new_password_again == "") {
                alert("新旧密码不能为空!");
                return;
            }
            if (old_password == new_password) {
                alert("旧密码与新密码相同!");
                return;
            }
            if (new_password != new_password_again) {
                alert("两次输入的密码不一致!");
                return;
            }

            $.ajax({
                url: "/FindAndUpdate/UpdateUser", //处理页面的路径
                data: {name: name, old_password: old_password, new_password: new_password},//要提交的数据是一个JSON
                type: "POST", //提交方式
                async: false,
                //TEXT字符串 JSON返回JSON XML返回XML
                success: function (data) { //回调函数 ,成功时返回的数据存在形参data里
                    alert(data);
                    if(data=="修改成功！请重新登录！")window.parent.location.href="login.html";
                }
            });
        }

    </script>
    <style>
        .alt td {
            background: black !important;
        }

        .Upatetext {
            width: 100%;
            height: 100%;
            text-align: left;
        }
    </style>
</head>
<body onload="getDate01()">
<div id="container">
    <div class="ui_content">
        <div class="ui_text_indent">
            <div id="box_border">
                <div id="box_top">修改信息</div>
                <input type="hidden" th:value="${session.User}" id="usercode"/>
                <div id="box_bottom">
                    <form>
                        <table id="usertable" class="table" cellspacing="0" cellpadding="0" width="50%" align="center"
                               border="0">
                           <!-- <tr>
                                <td>用户名:</td>
                                <td><input type="text" value="仅支持修改当前登录的用户！" onfocus="this.value=''"
                                           onblur="if(this.value=='')this.value='请输入您的用户名！'" name="username"
                                           id="username" class="Upatetext"></td>
                            </tr>-->
                            <tr>
                                <td>原密码:</td>
                                <td><input type="password" name="old_password" id="old_password" class="Upatetext"></td>
                            </tr>
                            <tr>
                                <td>新密码:</td>
                                <td><input type="password" name="new_password" id="new_password" class="Upatetext"></td>
                            </tr>
                            <tr>
                                <td>确认新密码:</td>
                                <td><input type="password" name="new_password_again" id="new_password_again"
                                           class="Upatetext"></td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <button class="ui_input_btn01" onclick="UpdateInformation()">提交</button>
                                </td>
                            </tr>

                        </table>
                    </form>
                </div>
            </div>

        </div>
    </div>
    <div class="ui_tb">
    </div>
    <div class="ui_content">
        <div class="ui_tb_h30">
            <div class="ui_flt" style="height: 30px; line-height: 30px;">

            </div>
            <div class="ui_frt">

            </div>
        </div>
    </div>
</div>
</body>
</html>
